package Offer.offer2020;

import domain.ListNode;

/**
 * 合并两个排序的链表
 */
public class Test17 {
    public static void main(String[] args) {

    }

    public static ListNode mergeListNode(ListNode head1, ListNode head2) {
        if (head1 == null) {
            return head2;
        }
        if (head2 == null) {
            return head1;
        }
        ListNode head;
        if (head1.val <= head2.val) {
            head = head1;
            head.next = mergeListNode(head1.next, head2);
        } else {
            head = head2;
            head.next = mergeListNode(head1, head2.next);
        }

        return head;
    }
}
